<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="url" value="${pageContext.request.contextPath}/" />
<link rel="stylesheet" href="${url }plugins/select2/select2.min.css">
<script src="${url }plugins/select2/select2.full.min.js"></script>
<script type="text/javascript">
$(function() {
	init();
});

function init(){
	var addIp =$("#addIp").val();
	$.ajax({
		type:"POST",
		url: path+'collect/getBeatInfo',
		data:{ip:addIp,beatName:'flowbeat'},
		success: function(result){
			$("#port").val(result.result.flowbeat.parameter.values.FLOWBEAT_PORT);
			$("#desc").val(result.result.flowbeat.parameter.values.DESC);
		}
	}); 
}

function addBeat(){
	$.ajax({
		cache:false,
		async:false,
		type:"POST",
		url: path
		+"collect/addFlowBeat",
		data:$('#beatForm').serialize(),
		success: function(result){
			if(result){
				alert("添加成功");
			}
		}
	});
}
</script>
<div class="box box-info">
	<div class="box-header with-border">
		<h3 class="box-title">FlowBeat / </h3>
		<!-- /.box-tools -->
	</div>
<!-- /.box-header -->
<form id="beatForm">
  <div class="box-body form-horizontal">
  	<div class="form-group">
       <label for="inputEmail3" class="col-sm-2 control-label">监听IP</label>
      <div class="col-sm-3">
        <input type="text" class="form-control" id="listenIp" placeholder="监听IP" value="${ip }" name="ip">
      </div>
    </div>
  	<div class="form-group">
       <label for="inputEmail3" class="col-sm-2 control-label">监听端口</label>
      <div class="col-sm-3">
        <input type="text" class="form-control" id="port" placeholder="监听端口" name="port">
      </div>
    </div>
  	<div class="form-group">
       <label for="inputEmail3" class="col-sm-2 control-label">描述</label>
      <div class="col-sm-3">
        <input type="text" id="desc" class="form-control" name="desc" placeholder="描述" >
      </div>
    </div>
     <div class="box-footer">
       <a type="button" class="btn btn-info" onclick="addBeat()">提交</a>
       <a href="javascript:linkByDom('local-list','${url }collect/getBeatList');" class="btn btn-default">取消</a>
    	<input type="hidden" value="${ip }" id="addIp" name="targetIp" />	
    </div>
  </div>
  </form>
</div>			            
